package com.wangsd.core.util;
                                                                                                                                                                                                                                                                      
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;                                                                                                                                                                                       
                                                                                                                                              
public class ExcelModelStyleUtil {
	
	//列样式  
	@SuppressWarnings("deprecation")
	public static void setTitleCellStyles(Workbook workbook,Sheet sheet){                                                       
		//设置单元格样式
		CellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		Font font = workbook.createFont();
		font.setFontHeightInPoints((short)11);//设置字体大小
		font.setColor(HSSFColor.BLUE_GREY.index);//颜色
		cellStyle.setFont(font);
		//设置列宽 ,第一个参数代表列id(从0开始),第2个参数代表宽度值		             
         sheet.setColumnWidth(0, 3000);                                           
         sheet.setColumnWidth(1, 5000);                                           
         sheet.setColumnWidth(2, 7000);                                           
         sheet.setColumnWidth(3, 5000);
         sheet.setColumnWidth(4, 3000);                                           
         sheet.setColumnWidth(5, 3000);                                           
         sheet.setColumnWidth(6, 5000);                                           
         sheet.setColumnWidth(7, 3000);
         sheet.setColumnWidth(8, 3000);
         sheet.setColumnWidth(9, 3000);
         sheet.setColumnWidth(10, 3000);
         sheet.setColumnWidth(11, 3000);
         sheet.setColumnWidth(12, 3000);
         sheet.setColumnWidth(13, 3000);
         sheet.setColumnWidth(14, 3000);
         for (int i = 0; i <= 14; i++){    
             sheet.setDefaultColumnStyle(i, cellStyle);//列样式      
         }
    } 
	
	// 列样式
	@SuppressWarnings("deprecation")
	public static void setTitleCellStylesNew(Workbook workbook, Sheet sheet) {
		// 设置单元格样式
		CellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		Font font = workbook.createFont();
		font.setFontHeightInPoints((short) 11);// 设置字体大小
		font.setColor(HSSFColor.BLUE_GREY.index);// 颜色
		cellStyle.setFont(font);
		// 设置列宽 ,第一个参数代表列id(从0开始),第2个参数代表宽度值
		sheet.setColumnWidth(0, 3000);
		sheet.setColumnWidth(1, 5000);
		sheet.setColumnWidth(2, 7000);
		sheet.setColumnWidth(3, 5000);
		sheet.setColumnWidth(4, 3000);
		sheet.setColumnWidth(5, 3000);
		sheet.setColumnWidth(6, 5000);
		sheet.setColumnWidth(7, 3000);
		sheet.setColumnWidth(8, 3000);
		sheet.setColumnWidth(9, 3000);
		sheet.setColumnWidth(10, 3000);
		sheet.setColumnWidth(11, 3000);
		sheet.setColumnWidth(12, 3000);
		sheet.setColumnWidth(13, 3000);
		sheet.setColumnWidth(14, 3000);
		for (int i = 0; i <= 14; i++) {
			sheet.setDefaultColumnStyle(i, cellStyle);// 列样式
		}
	}
	
}                                                                                                                                            